// 统一发送请求
import ajax from '@/api/ajax'
import mockAjax from '@/api/mockAjax'

// 获取三级导航数据
export const reqGetNavigationList = () => ajax.get("/product/getBaseCategoryList")

// 获取轮播图数据 
export const reqGetBannerList = () => mockAjax.get('/banner')

// 获取楼层数据
export const reqGetFloorsList = () => mockAjax.get('/floors')

// 获取搜索页数据
export const reqGetSearchData = (query) => ajax.post('/list', query)

// 登录请求
export const reqGetUserLogin = (params) => ajax.post('user/passport/login', params)

// 注册
export const reqRegistration = (user) => ajax.post('/user/passport/register', user)

// 退出登录
export const reqLaunchLogin = () => ajax.get('/user/passport/logout')

// 获取验证码
export const getVerificationCode = (phone) => ajax.get(`/user/passport/sendCode/${phone}`)

// 详情页数据
export const reqGetDetailsData = (id) => ajax.get('item/' + id)


// 添加到购物车/修改数量
export const reqAddUpdateCart = (id, num) => ajax.post(`/cart/addToCart/${id}/${num}`)

// 获取购物车数据
export const reqGetCartList = () => ajax.get('/cart/cartList')

// 购物车修改数据/全选全不选
export const reqUpdateIsChecked = (skuId, isChecked) => ajax.get(`/cart/checkCart/${skuId}/${isChecked}`)

// 删除
export const checkDeleteCart = (skuId) => ajax.delete(`/cart/deleteCart/${skuId}`)


/* 
opost  /api/cart/batchCheckCart/{isChecked}
批量选中购物车
参数：skuIdList  数组  代表修改的商品id列表     请求体参数
      isChecked  要修改的状态   1代表选中  0代表未选中
       */
export const updateCheckedAll = (isChecked, skuIdList) => ajax.post(`/cart/batchCheckCart/${isChecked}`, skuIdList)

// 批量删除购物车，请求体参数
export const reqBatchDelete = (skuIdList) => ajax.delete('/cart/batchDeleteCart', { data: skuIdList })


// 提交订单
export const reqGetPlaceOrder = (tradeNo, params) => ajax.post(`/order/auth/submitOrder?tradeNo=${tradeNo}`, params)

// 获取支付二维码
export const reqPaymentDate = (orderId) => ajax.get(`/payment/weixin/createNative/${orderId}`)

// 查询订单支付情况
export const QueryPaymentStatus = (orderId) => ajax.get(`/payment/weixin/queryPayStatus/${orderId}`)

// 获取客户地址信息
export const reqCustomerAddress = () => ajax.get(`/user/userAddress/auth/findUserAddressList`)

// 获取交易页信息
export const reqGetOrderList = () => ajax.get('/order/auth/trade')


// 获取订单
export const reqGetOrderInformation = (page, limit) => ajax.get(`/order/auth/${page}/${limit}`)
